package com.liveinstars.account.application.assembler;

import com.liveinstars.account.business.domain.bo.User;
import com.liveinstars.api.dto.BindInfo;
import com.liveinstars.api.dto.GetUserInfo;
import com.liveinstars.api.dto.GetUserInfoAndBind;
import com.liveinstars.api.dto.ImGetUserInfo;
import org.apache.commons.lang.StringUtils;
import org.springframework.lang.NonNull;

public class AccountAssembler {


    public static ImGetUserInfo toImUserInfo(@NonNull User user) {

        ImGetUserInfo getUserInfo = new ImGetUserInfo();
        getUserInfo.setUid(Long.valueOf(user.getId()));
        getUserInfo.setUserName(StringUtils.isEmpty(user.getNickName()) ?  user.getUserName() : user.getNickName());
        getUserInfo.setNickName(user.getNickName());
        getUserInfo.setLogo(user.getAvatar());
        getUserInfo.setMobile(user.getPhone());
        return getUserInfo;
    }

    public static GetUserInfo toUserInfo(@NonNull User user) {

        GetUserInfo getUserInfo = new GetUserInfo();
        getUserInfo.setUid(user.getId());
//        getUserInfo.setUserName(user.getUserName());
        getUserInfo.setUserName(StringUtils.isEmpty(user.getNickName()) ?  user.getUserName() : user.getNickName());
        getUserInfo.setNickName(user.getNickName());
        getUserInfo.setLogo(user.getAvatar());
        getUserInfo.setMobile(user.getPhone());
        return getUserInfo;
    }

    public static GetUserInfoAndBind toUserInfoAndBind(User user, BindInfo bindInfo) {
        GetUserInfoAndBind getUserInfo = new GetUserInfoAndBind();
        getUserInfo.setUid(user.getId());
//        getUserInfo.setUserName(user.getUserName());
        getUserInfo.setUserName(StringUtils.isEmpty(user.getNickName()) ?  user.getUserName() : user.getNickName());
        getUserInfo.setNickName(user.getNickName());
        getUserInfo.setLogo(user.getAvatar());
        getUserInfo.setMobile(user.getPhone());
        getUserInfo.setBindInfo(bindInfo);
        return null;
    }
}
